package com.yohann.course_service.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yohann.course_service.entity.Subject;
import com.yohann.course_service.mapper.SubjectMapper;
import com.yohann.course_service.service.SubjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 课程分类 服务实现类
 * </p>
 *
 * @author Yohann
 * @since 2020-10-18
 */
@Service
public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> implements SubjectService {
    /**
     * 分页查询课程分类
     *
     * @param page
     * @return
     */
    @Override
    public Map<String, Object> pageQuerySubject(Page<Subject> page) {
        baseMapper.selectPage(page, null);

        //将查询到的总条数、结果集存入map中并返回
        Map<String, Object> map = new HashMap<>();
        map.put("total", page.getTotal());
        map.put("rows", page.getRecords());
        return map;
    }
}
